import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetTimePeriodNameHint_ {
  /**
   * @description 统计粒度中文名称关键字
   * @example adas
   */
  cnName?: string;
}
export interface GetTimePeriodById_ {
  /**
   * @description 主键id
   */
  id: number;
}
export interface PutTimePeriodById_ {
  /**
   * @description 主键id
   */
  id: number;
}
export interface DeleteTimePeriodById_ {
  /**
   * @description 主键id
   */
  id: number;
}

export class TimePeriod {
  /**
   * 添加统计粒度词
   *
   * @tags 统计粒度
   * @request POST: /time-period
   * @secure
   */
  postTimePeriod = (body: defs.TimePeriodDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityTimePeriodVO>({
      url: `/time-period`,
      method: "POST",
      data: body,
      ...params,
    });

  /**
   * 删除统计粒度词
   *
   * @tags 统计粒度
   * @request POST: /time-period/batch-delete
   * @secure
   */
  postTimePeriodBatchDelete = (ids: number[], params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/time-period/batch-delete`,
      method: "POST",
      data: ids,
      ...params,
    });

  /**
   * 获取统计粒度词列表
   *
   * @tags 统计粒度
   * @request POST: /time-period/list
   * @secure
   */
  postTimePeriodList = (body: defs.TimePeriodQueryDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityPageInfoTimePeriodVO>({
      url: `/time-period/list`,
      method: "POST",
      data: body,
      ...params,
    });

  /**
   * 下拉统计粒度id
   *
   * @tags 统计粒度
   * @request GET: /time-period/name-hint
   * @secure
   */
  getTimePeriodNameHint = (query: { cnName?: string } | GetTimePeriodNameHint_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListTimePeriodVO>({
      url: `/time-period/name-hint`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 根据id获取统计粒度信息
   *
   * @tags 统计粒度
   * @request GET: /time-period/{id}
   * @secure
   */
  getTimePeriodById = ({ id }: { id: number } | GetTimePeriodById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityTimePeriodVO>({
      url: `/time-period/${id}`,
      method: "GET",
      ...params,
    });

  /**
   * 更新统计粒度词的元数据信息
   *
   * @tags 统计粒度
   * @request PUT: /time-period/{id}
   * @secure
   */
  putTimePeriodById = (
    { id }: { id: number } | PutTimePeriodById_,
    body: defs.TimePeriodDTO,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityTimePeriodVO>({
      url: `/time-period/${id}`,
      method: "PUT",
      data: body,
      ...params,
    });

  /**
   * 删除统计粒度词
   *
   * @tags 统计粒度
   * @request DELETE: /time-period/{id}
   * @secure
   */
  deleteTimePeriodById = ({ id }: { id: number } | DeleteTimePeriodById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/time-period/${id}`,
      method: "DELETE",
      ...params,
    });
}

export default new TimePeriod();
